package com.sky.service.impl;

import com.sky.entity.DishFlavor;
import com.sky.mapper.DishFlavorMapper;
import com.sky.mapper.DishMapper;
import com.sky.mapper.UserDishMapper;
import com.sky.service.UserDishService;
import com.sky.vo.DishVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class UserDishServiceImpl implements UserDishService {


    @Autowired
    private UserDishMapper dishMapper;

    @Autowired
    private DishFlavorMapper dishFlavorMapper;
    /**
     * 根据分类id查询菜品
     * @param categoryId
     * @return
     */
    @Override
    public List<DishVO> getDishByCategoryId(String categoryId) {
        List<DishVO> list = dishMapper.selectDishByCategoryId(categoryId);
        for (DishVO dish : list) {
            dish.setFlavors(dishFlavorMapper.selectDishFlavorById(dish.getId()));
        }
        return list;
    }

}
